package com.example.xmlfactory.parse;

/**
 * Created by huangbei on 2017/9/11.
 */

public class Var {
    private String name;
    private String type;
    private Object value;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(String value){
        if(type.endsWith("String")){
            this.value = value;
        }else if(type.endsWith("int")||type.endsWith("Integer")){
            this.value = Integer.parseInt(value);
        }else if(type.endsWith("boolean")){
            this.value = Boolean.parseBoolean(value);
        }else if(type.endsWith("Long")||type.endsWith("long")){
            this.value = Long.parseLong(value);
        }else if(type.endsWith("Float")||type.endsWith("float")){
            this.value = Float.parseFloat(value);
        }
    }

    public void setValue(Object obj){
        this.value = obj;
    }

    public void clearValue(){
        if(value != null){
            value = null;
        }
    }
}
